package com.shopping.servlets;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/*
* 用户退出系统
* 从session中将user对象移除
* */
@WebServlet("/exit.do")
public class ExitServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获得session
        HttpSession session = request.getSession();
        //从session中移除属性名为user的属性
        session.removeAttribute("user");
        response.sendRedirect("index.jsp");
    }
}
